package com.markerhub.controller;


import com.markerhub.common.lang.Result;
import com.markerhub.entity.ClassType;
import com.markerhub.service.ClassTypeService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/class-type")
public class ClassTypeController {
    @Autowired
    private ClassTypeService classTypeService;



    // 教学班类型相关接口
    @RequiresRoles("root")
    @GetMapping("/class-types")
    public Result listClassTypes() {
        return Result.succ(classTypeService.list());
    }

    @RequiresRoles("root")
    @PostMapping("/class-type")
    public Result saveClassType(@RequestBody ClassType classType) {
        classTypeService.saveOrUpdate(classType);
        return Result.succ("操作成功");
    }

    @RequiresRoles("root")
    @DeleteMapping("/class-type/{id}")
    public Result deleteClassType(@PathVariable Integer id) {
        classTypeService.removeById(id);
        return Result.succ("删除成功");
    }
}
